import { MjWeaveItem } from "./MjWeaveItem";

export class MjHuTypeModel {

    public huType: number = 0
    public huTypeZu: Map<number, number> = new Map<number, number>()//
    public huData: number = 0
    public leftDataList: Array<number>;
    public leftDataAndHuData: Array<number>
    public jiangData: number = 0; //将牌 或者说是对眼的牌
    public mjWeaveList: Array<MjWeaveItem>
    public allDataList: Array<number>

    public leftRightList: Array<Array<number>> = []
    public allRightList: Array<Array<number>> = []

    public dianpao:number = 0

    public static json2Model(jsonObj: object) {
        let huType: MjHuTypeModel = new MjHuTypeModel()
        huType.huType = jsonObj["huType"]
        huType.huTypeZu = new Map<number, number>()
        for (const key in jsonObj["huTypeZu"]) {
            huType.huTypeZu.set(parseInt(key), jsonObj["huTypeZu"][key])
        }

        huType.huData = jsonObj["huData"]
        huType.leftDataList = jsonObj["leftDataList"]
        huType.leftDataAndHuData = jsonObj["leftDataAndHuData"]
        huType.jiangData = jsonObj["jiangData"]
        let waveListObj: Array<object> = jsonObj["mjWeaveList"]
        huType.mjWeaveList = []
        for (let i = 0; i < waveListObj.length; i++) {
            huType.mjWeaveList[i] = MjWeaveItem.json2MjWeaveItem(waveListObj[i])
        }
        huType.allDataList = jsonObj["allDataList"]
        huType.dianpao = jsonObj["dianpao"]
        return huType
    }

}